package Exercise;

import java.util.Arrays;

/**
 * Description：
 * Author: zhangc
 * Date：2017/8/22 22:50
 */
public class StatusArray {

    public static int[] getStatus(int[] array) {
        int[] status = new int[ array.length ];
        for (int i = array.length - 1; i >= 0; i--) {
            status[ i ] = -1;
            for (int j = i - 1; j >= 0; j--) {
                if (array[ i ] > array[ j ]) {
                    status[ i ] = array[ j ];
                    break;
                }
            }
        }
        return status;
    }


    public static void main(String[] args) {
        int[] arr = {3, 6, 1, 4, 2, 3, 7, 5, 8};
        int[] status = getStatus(arr);
        System.out.println(Arrays.toString(status));
    }

}
